package bjtu.cit.bookshop.service.impl;

import bjtu.cit.bookshop.daos.EmployeeMapper;
import bjtu.cit.bookshop.entities.Employee;
import bjtu.cit.bookshop.service.IEmployeeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by jia19 on 2015/9/22.
 */
@Service("employeeService")
public class EmployeeService implements IEmployeeService {

    @Resource
    private EmployeeMapper employeeMapper = null;

    @Override
    public int createAEmployee(Employee employee) {
        return this.employeeMapper.insertSelective(employee);
    }

    @Override
    public Employee getEmployeeById(int id) {
        return this.employeeMapper.selectByPrimaryKey(id);
    }

    @Override
    public Employee getEmployeeByUsername(String username) {
        return this.employeeMapper.selectByUsername(username);
    }

    @Override
    public int deleteById(int id) {
        return this.employeeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateEmployeeInfo(Employee employee) {
        return this.employeeMapper.updateByPrimaryKeySelective(employee);
    }

    @Override
    public List<Employee> getEmployeeList() {
        return this.employeeMapper.selectEmployeeList();
    }
}
